# -*- coding:utf-8 -*-

from fastapi import FastAPI, APIRouter

# from .website.api import router as website_router
from api.user import router as user_router
from api.role import router as role_router
from api.permision import router as permision_router
from api.attachment import router as attachment_router
from api.auth import router as auth_router


from config.env import AppConfig
admin_controllers = [
    {'router': user_router, 'prefix': '/api/v1/admin', 'tags': ['用户模块']},
    {'router': role_router, 'prefix': '/api/v1/admin', 'tags': ['角色模块']},
    {'router': permision_router, 'prefix': '/api/v1/admin', 'tags': ['权限模块']},
    {'router': attachment_router, 'prefix': '/api/v1/admin', 'tags': ['附件模块']},
    {'router': auth_router, 'prefix': '/api/v1/admin', 'tags': ['验证模块']},
]

website_controllers = [
    # {'router': website_router, 'prefix': '', 'tags': ['门户模块']},
]


def register_router(app: FastAPI):
    all_router = APIRouter(prefix= AppConfig.api_prefix)
    for router in admin_controllers:
        all_router.include_router(router=router['router'], prefix=router['prefix'], tags=router['tags'])
    for router in website_controllers:
        all_router.include_router(router=router['router'], prefix=router['prefix'], tags=router['tags'])
    app.include_router(all_router)